local AceGUI = LibStub('AceGUI-3.0')

-- 利用函数给第一个选项绘制模版
local function DrawGroup1(container)
    local desc = AceGUI:Create("Label")
    desc:SetText("This is Tab 1")
    desc:SetFullWidth(true)
    container:AddChild(desc)
    
    local button = AceGUI:Create("Button")
    button:SetText("Tab 1 Button")
    button:SetWidth(200)
    container:AddChild(button)
  end
  
  -- 第二个
  local function DrawGroup2(container)
    local desc = AceGUI:Create("Label")
    desc:SetText("This is Tab 2")
    desc:SetFullWidth(true)
    container:AddChild(desc)
    
    local button = AceGUI:Create("Button")
    button:SetText("Tab 2 Button")
    button:SetWidth(200)
    container:AddChild(button)
  end
  
  -- 回调函数OnGrioupSelected
  local function SelectGroup(container, event, group)
     container:ReleaseChildren()
     if group == "tab1" then
        DrawGroup1(container)
     elseif group == "tab2" then
        DrawGroup2(container)
     end
  end
  
  -- 创建骨架
  local frame = AceGUI:Create("Frame")
  frame:SetTitle("Example Frame")
  frame:SetStatusText("AceGUI-3.0 Example Container Frame")
  frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
  -- Fill Layout - the TabGroup widget will fill the whole frame
  frame:SetLayout("Fill")
  
  -- 创建选项组
  local tab =  AceGUI:Create("TabGroup")
  tab:SetLayout("Flow")
  -- 设置哪些显示哪些选项
  tab:SetTabs({{text="Tab 1", value="tab1"}, {text="Tab 2", value="tab2"}})
  -- 注册回调函数
  tab:SetCallback("OnGroupSelected", SelectGroup)
  -- 设置初始选项卡 (这里将调用OnGroupSelected)
  tab:SelectTab("tab1")
  
  -- 加入骨架
  frame:AddChild(tab)
  